<%--
    活动审批界面
    Author: scm
    Date: 2023-12-12
    Version: 1.0
--%>
<%--
    需要的数据
    activityApplicationList 根据搜索框输入的活动标题（可能不完整），返回查找到的所有符合的activityApplication
    如果搜索框没输入，则返回所有activityApplication

    currentPage 就是页面传入的参数page（具体见本页面“分页展示部分”）
    totalPage 总数/每页展示的数（我这里设置的10）

    传入的数据
    keyword 搜索的关键词（见搜索部分）
    page 当前页面号（见分页展示部分）
    id 审核通过/不通过的activityApplicationID（见审核按钮部分）
--%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page session="true" %>
<%@ page contentType="text/html; charset=UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="<c:url value="/resources/css/bootstrap.css"/>">
    <link rel="stylesheet" href="<c:url value="/resources/css/systemStyle.css"/>">
    <title>校园社团管理系统</title>
</head>
<body>
<!-- 顶部导航栏 -->
<jsp:include page="./header.jsp" />
<div class="content container">
    <!-- 搜索框  -->
    <nav class="navbar bg-body-tertiary">
        <div class="container-fluid">
            <div class="fs-4 fw-bolder">社团活动申请记录</div>
            <form class="d-flex" role="search" action="<c:url value="../systemAdministrator/clubApplications" />" method="get">
                <input type="search" class="form-control me-2" placeholder="输入活动标题" name="keyword" aria-label="Search">
                <button class="btn btn-outline-success text-nowrap" type="submit" id="search">搜索</button>
            </form>
        </div>
    </nav>
    <!-- activityApplication信息列表  -->
    <c:if test="${not empty activityApplicationList}">
        <table class="table table-hover">
            <thead>
            <tr>
                <th scope="col" class="text-center">ID</th>
                <th scope="col">活动标题</th>
                <th scope="col">开始时间</th>
                <th scope="col">结束时间</th>
                <th scope="col">地点</th>
                <th scope="col">状态</th>
                <th scope="col" colspan="2" class="text-center">操作</th>
            </tr>
            </thead>

            <c:forEach items="${activityApplicationList}" var="activityApplication" varStatus="loop" begin="${(currentPage-1)*10}" end="${currentPage*10-1}">
                <tr>
                    <th class="text-center">${activityApplication.activityApplicationID}</th>
                    <td>${activityApplication.pendingActivity.activityName}</td>
                    <td><fmt:formatDate value="${activityApplication.pendingActivity.startTime}" pattern="yyyy/MM/dd HH:mm" /></td>
                    <td><fmt:formatDate value="${activityApplication.pendingActivity.endTime}" pattern="yyyy/MM/dd HH:mm" /></td>
                    <td>${activityApplication.pendingActivity.place}</td>
                    <td>
                        <c:choose>
                            <c:when test="${activityApplication.status == 0}">
                                待审
                            </c:when>
                            <c:when test="${activityApplication.status == -1}">
                                拒绝
                            </c:when>
                            <c:when test="${activityApplication.status == 1}">
                                通过
                            </c:when>
                        </c:choose>
                    </td>
                    <c:choose>
                        <c:when test="${activityApplication.status == 0}">
                            <td class="text-center">
                                <!-- 审核通过按钮 -->
                                <form action="<c:url value="../systemAdministrator/activityApplications/pass" />" method="post">
                                    <input type="hidden" name="id" value="${activityApplication.activityApplicationID}" />
                                    <input type="submit" class="btn btn-outline-success" value="通过" />
                                </form>
                            </td>
                            <td class="text-center">
                                <!-- 审核不通过按钮 -->
                                <form action="<c:url value="../systemAdministrator/activityApplications/rejected" />" method="post">
                                    <input type="hidden" name="id" value="${activityApplication.activityApplicationID}" />
                                    <input type="submit" class="btn btn-outline-danger" value="拒绝" />
                                </form>
                            </td>
                        </c:when>
                        <c:when test="${activityApplication.status != 0}">
                            <td colspan="2" class="text-center">
                                <input type="submit" class="btn btn-outline-success" value="已审核" disabled/>
                            </td>
                        </c:when>
                    </c:choose>
                </tr>
            </c:forEach>
        </table>
        <!-- 分页展示 -->
        <div class="d-flex justify-content-evenly">
            <c:if test="${currentPage > 1}">
                <div class="pre-page">
                    <a href="<c:url value="../systemAdministrator/activityApplications?page=${currentPage - 1}" />" class="btn btn-outline-secondary">&lt; 上一页</a>
                </div>
            </c:if>
            <c:if test="${currentPage <= 1}">
                <div class="pre-page">
                    <a href="<c:url value="../systemAdministrator/activityApplications?page=${currentPage - 1}" />" class="btn btn-outline-secondary disabled">&lt; 上一页</a>
                </div>
            </c:if>
            <p class="currentPage ">第 ${currentPage} 页</p>
            <c:if test="${currentPage < totalPage}">
                <div class="next-page">
                    <a href="<c:url value="../systemAdministrator/activityApplications?page=${currentPage + 1}" />" class="btn btn-outline-secondary">下一页 &gt;</a>
                </div>
            </c:if>
            <c:if test="${currentPage >= totalPage}">
                <div class="next-page">
                    <a href="<c:url value="../systemAdministrator/activityApplications?page=${currentPage + 1}" />" class="btn btn-outline-secondary disabled">下一页 &gt;</a>
                </div>
            </c:if>
        </div>
    </c:if>
    <c:if test="${empty activityApplicationList}">
        <p class="text-center text-danger">无申请记录</p>
    </c:if>
</div>
<jsp:include page="./footer.jsp" />
<script src="<c:url value="/resources/js/bootstrap.bundle.js" />"></script>
</body>
</html>